﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using Yelper.Web.Validators;

namespace Yelper.Web {

    [MetadataType(typeof(User_Validation))]
    public partial class User {

        [Required(ErrorMessage="This field is required.")]
        [Display(Name="Password")]
        public string PlainTextPassword { get; set; }

        [Required(ErrorMessage = "This field is required.")]
        [Compare("PlainTextPassword",ErrorMessage="Both passwords must match.")]
        [Display(Name = "Repeat this password")]
        public string ConfirmPlainTextPassword { get; set; }

    }

    [Bind(Exclude="UserId")]
    public class User_Validation {

        [Required(ErrorMessage = "This field is required.")]
        [Display(Name = "Choose a username")]
        [StringLength(35,ErrorMessage="That is too long!")]
        [Username(ErrorMessage="This is not a valid username")]
        [Remote("CheckUsernameAvailable", "Ajax", ErrorMessage="This username is not available.")]
        public string Username { get; set; }

        [Required(ErrorMessage = "This field is required.")]
        [Email(ErrorMessage = "Please enter a valid email.")]
        [StringLength(150, ErrorMessage = "That is too long!")]
        [Display(Name = "Email address")]
        public string Email { get; set; }

        [Required(ErrorMessage = "This field is required.")]
        [StringLength(50, ErrorMessage = "That is too long!")]
        [Display(Name = "Full name")]
        public string FullName { get; set; }

        [Url(ErrorMessage = "This is not a valid url.")]
        public string Website { get; set; }

        [StringLength(1000, ErrorMessage = "That is too long!")]
        public string Bio { get; set; }

    }

}